﻿/*****************************************************************//**
 * @file    FITKColorMapManager.h
 * @brief   The color map manager of the model.
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-05-11
 *********************************************************************/

#ifndef __FITKCOLORMAPMANAGER_H__
#define __FITKCOLORMAPMANAGER_H__

#include <QObject>

#include <QHash>

// Forward declaration
namespace Exchange
{
    class FITKColorMap;
}

namespace Exchange
{
    /**
     * @brief   The color map manager of the all part or instance's part.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-05-11
     */
    class FITKColorMapManager : public QObject
    {
        Q_OBJECT
    public:
        /**
         * @brief   Get the instance of this class.[static]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-11
         */
        static FITKColorMapManager* getInstance();

        /**
         * @brief   Delete the instance.[static]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-11
         */
        static void Destory();

        /**
         * @brief   Get the color map of the part with the given part data id,
         *          create a new one if the dict does'n have the color map.
         * @param   partId: The part id
         * @return  The color map pointer
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-11
         */
        FITKColorMap* getPartColorMap(int partId);

    private:
        /**
         * @brief   Constructure.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-11
         */
        FITKColorMapManager() = default;

        /**
         * @brief   Desturcture.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-11
         */
        virtual ~FITKColorMapManager();

    private:
        /**
         * @brief   The instance of the class.[static]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-11
         */
        static FITKColorMapManager* s_instance;
        
        /**
         * @brief   The dict of the part data id and color map.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-11
         */
        QHash<int, FITKColorMap*> m_partColorMapHash;

    };
}   // namespace Exchange

#endif // __FITKCOLORMAPMANAGER_H__
